
package Usefull;
import java.io.*;
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.opengl.*;
import org.lwjgl.*;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
/**
 * Utils.java
 * Created on May 5, 2014
 * Author Joe Porter
 */

public class Utils {

    DisplayMode displayMode;
        
        int screenX,screenY,
                fps;
        
        String displayTitle;
        
        Display display;
    
    public void InitOGL(int screenX, int screenY){
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, screenX, screenY, 0, 1, -1);
        glMatrixMode(GL_MODELVIEW);
        glEnable(GL_TEXTURE_2D);
    }
    
    public Texture loadTexture(String fileType, String location){
            try {
                return TextureLoader.getTexture(fileType, new FileInputStream(new File("res/" + location + "." + fileType)));
            } catch (IOException ex) {
                ex.printStackTrace();
                System.exit(0);
            }
            return null;
        }
    
    public void CreateDisplay(int screenX,int screenY, String title){
            this.screenX = screenX;
            this.screenY = screenY;
            this.fps = fps;
            displayTitle = title;
            try{
            DisplayMode[] modes = display.getAvailableDisplayModes();
            for (int i = 0; i < modes.length; i++)
         {
             if (modes[i].getWidth() == screenX
             && modes[i].getHeight() == screenY
             && modes[i].isFullscreenCapable())
               {
                    displayMode = modes[i];
               }
         }
            display.setDisplayMode(displayMode);
            display.setTitle(displayTitle);
            display.create();            
            
        } catch(LWJGLException e){
            e.printStackTrace();
            System.exit(0);
        }
        }
}
